import sbt._
import Keys._
import com.github.siasia._

object BuildSettings
{
  val buildOrganization = "pub"
  val buildVersion = "0.1"
  val buildScalaVersion = "2.9.0-1"

  val buildSettings = Defaults.defaultSettings ++ bees.RunCloudPlugin.deploymentSettings ++ WebPlugin.webSettings ++
    Seq(
      organization := buildOrganization,
      version := buildVersion,
      scalaVersion := buildScalaVersion,
      checksums := Nil,
      resolvers ++= Seq(
        "Scala-Tools Snapshots" at "http://scala-tools.org/repo-snapshots/",
        "mandubian-mvn" at "http://mandubian-mvn.googlecode.com/svn/trunk/mandubian-mvn/repository",
        "com.asual.maven.public" at "http://www.asual.com/maven/content/groups/public",
        "twitter4j.org" at "http://twitter4j.org/maven2",
        "jwall" at "http://secure.jwall.org/maven/repository/jwall/",
        "Java.net Maven2 Repository" at "http://download.java.net/maven/2/"
      )
    )
}

object Dependencies
{
  val liftVer = "2.4-M3"
  val jettyVer = "6.1.26"

  val liftweb = "net.liftweb" %% "lift-webkit" % liftVer
  val liftrecord = "net.liftweb" %% "lift-record" % liftVer
  val liftutil = "net.liftweb" %% "lift-util" % liftVer
  val liftactor = "net.liftweb" %% "lift-actor" % liftVer
  val liftcommon = "net.liftweb" %% "lift-common" % liftVer
  val liftjson = "net.liftweb" %% "lift-json" % liftVer
  val liftjsonext = "net.liftweb" %% "lift-json-ext" % liftVer
  val liftsquerrec = "net.liftweb" %% "lift-squeryl-record" % liftVer
  val liftmongorec = "net.liftweb" %% "lift-mongodb-record" % liftVer
  val liftwidgets = "net.liftweb" %% "lift-widgets" % liftVer
  val slf4j = "org.slf4j" % "slf4j-log4j12" % "[1.6.1,)"
  val gdatacontacts = "com.google.gdata" % "gdata-contacts-3.0" % "1.41.5"
  val gdataphotos = "com.google.gdata" % "gdata-photos-2.0" % "1.41.5"
  val lesscss = "com.asual.lesscss" % "lesscss-engine" % "[1.0.41,)"
  val lesscssservlet = "com.asual.lesscss" % "lesscss-servlet" % "[1.0.41,)"
  val httpclient = "org.apache.httpcomponents" % "httpclient" % "[4.1.1,)"
  val servlet = "javax.servlet" % "servlet-api" % "2.5" % "provided->default"
  val twitter = "org.twitter4j" % "twitter4j-core" % "[2.2,)"
  val restfb = "com.restfb" % "restfb" % "[1.6.4,)"
  val commonslang = "commons-lang" % "commons-lang" % "2.6"
  val rogue = "com.foursquare" %% "rogue" % "1.0.15"
  val mysql = "mysql" % "mysql-connector-java" % "[5.1.15,)" % "test->default"
  val h2 = "com.h2database" % "h2" % "1.3.157" % "test"
  val postgres = "postgresql" % "postgresql" % "9.0-801.jdbc4" % "test"
  val jetty = "org.mortbay.jetty" % "jetty" % jettyVer % "jetty"
  val jettyutil = "org.mortbay.jetty" % "jetty-util" % jettyVer % "jetty"
  val jettyman = "org.mortbay.jetty" % "jetty-management" % jettyVer % "test->default"
  val junit = "junit" % "junit" % "4.8.2" % "test->default"
  val testng = "org.testng" % "testng" % "6.0.1" % "test->default"
  val scalatest = "org.scalatest" % "scalatest_2.9.0" % "1.6.1" % "test->default"

  val commonDeps = Seq(slf4j, commonslang)

  val testDeps = Seq(junit, testng, scalatest)

  val liftDeps = Seq(liftweb, liftrecord, liftutil, liftactor, liftcommon, liftjson, liftjsonext, liftsquerrec,
    liftmongorec, liftwidgets)

  val webDeps = commonDeps ++ testDeps ++ liftDeps ++ Seq(gdatacontacts, gdataphotos, lesscss, lesscssservlet,
    httpclient, servlet, twitter, restfb, rogue, mysql, h2, postgres, jetty, jettyutil, jettyman)
}

object PublisherBuild extends Build
{

  import BuildSettings._
  import Dependencies._

  lazy val publisher = Project(
    "smm", file("."), settings = buildSettings
  ) aggregate (web, parsing)

  lazy val web = Project(
    "web", file("smm-web"), settings = buildSettings ++ Seq(libraryDependencies ++= webDeps)
  ) dependsOn (parsing)

  lazy val parsing = Project(
    "parsing", file("smm-pasing"), settings = buildSettings ++ Seq(libraryDependencies ++= commonDeps)
  )
}